<!--
 * @Descripttion: 
 * @version: 
 * @Author: 
 * @Date: 2022-05-05 14:25:40
 * @LastEditors: weidelong
 * @LastEditTime: 2022-05-20 15:06:48
-->
<template>
    <div class="home">
        <headnav></headnav>
        <div class="main">
            <leftnav></leftnav>
            <div class="content">
                <!-- 主体 -->
                <router-view />
            </div>
        </div>
    </div>
</template>

<script>
    import headnav from '../components/head/head'
    import leftnav from '../components/head/nav'
    
    export default {
        name: 'Home',
        components: {
            headnav,
            leftnav
        },
        data() {
            return {
                
            }
        },
        sockets: {
            disconnect() {
                console.log('断开连接')
                this.$socket.emit('state', { state: false })
            }
        },
		mounted () {
            // 刷新重连
            try {
                const username = localStorage.getItem("username")
                if (username) {
                    this.$socket.connect()
                }
            } catch (error) {
                console.log(error)
            }
            // 监听文章提醒
            this.sockets.subscribe("articleRemind", data => {
                this.$store.commit('setArticleRemind', data)
                if (this.$store.state.username?.flag !== 'doctor') {
                    this.open3()
                }
            })
        
		},
		methods: {
			open3() {
				this.$notify.info({
					title: '消息',
					message: '您有一条新的消息提醒'
				})
			}
		}
    }
</script>

<style lang="scss" scoped>
    .home {
        width: 100%;
        height: 100%;
        .main {
            width: 100%;
            height: calc(100% - 80px);
            background: #F1F5F9;
            display: flex;
            .content {
                padding: 12px;
                box-sizing: border-box;
                width: 100%;
                height: 100%;
                div {
                    background: #fff;
                    width: 100%;
                    height: 100%;
                }
            }
        }
    }
</style>
